Zip for UWP
ユーザーのコンピュータから Zip ファイルを開く
タスク別ヘルプ > ユーザーのコンピュータから Zip ファイルを開く

FileOpenPicker クラスを使用して、ユーザーがドキュメントライブラリから zip ファイルを選択して開くことができるようにします。次のコードを使用して、C1Zip でファイルを開きます。また、このサンプルは、結果を表示するために、ページに "flex" という名前の C1FlexGrid コントロールがあることを前提としています。ただし、そうしなければならないというわけではありません。

C# コードの書き方

C#
コードのコピー
// 既存の zip ファイルを開きます
async void _btnOpen_Click_1(object sender, RoutedEventArgs e)
{
C1ZipFile zip = new C1ZipFile(new System.IO.MemoryStream(), true);
try
{
var picker = new Windows.Storage.Pickers.FileOpenPicker();
picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
picker.FileTypeFilter.Add(".zip");
var file = await picker.PickSingleFileAsync();
if (file != null)
{
var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite);
zip.Open(stream.AsStream());

// FlexGrid にエントリをロードします
flex.ItemsSource = zip.Entries;
}
}
catch (Exception x)
{
System.Diagnostics.Debug.WriteLine(x.Message);
}
}
関連トピック